$(function() {
	var sele = GetRequest();
	var query = new AV.Query('Product');
	query.equalTo('id', sele);
	query.find().then(function(results) {
		console.log(results);
		var src = results[0].attributes.image.split(";");
		console.log()
		$(".shangpindatu_dj").children()[0].src = src[0];
		var xiaotus = $("#xiaotu_dj").children();
		for(var i = 0; i < xiaotus.length; i++) {
			xiaotus[i].children[0].children[0].src = src[i];
		}
		var title = $("#zhongbutopcenter_dj>p");
		title.html(results[0].attributes.title);
		$(".zhongbutopcenter_dj").children().html(results[0].attributes.jianjie);
		$(".shoujia_dj").html(results[0].attributes.price);
		$(".zhanshitu_dj").html(results[0].attributes.detail);
	}, function(error) {});
	$(".gouwuche_dj").click(function() {
		var currentUser = AV.User.current();
		var username = currentUser._serverData.username
		var Product = AV.Object.extend('gouwuche');
		var product = new Product();
		var startDateQuery = new AV.Query('gouwuche');
		startDateQuery.equalTo('username', username);
		var endDateQuery = new AV.Query('gouwuche');
		endDateQuery.equalTo('id', sele);
		var query = AV.Query.and(startDateQuery, endDateQuery);
		query.find().then(function(results) {
			if(results.length == 0) {
				product.set('id', sele);
				product.set('username', username);
				product.set('num', "1");
				product.save().then(function() {
					//  发布成功，跳转到商品 list 页面
					alert('添加成功');
					setnull();
				}, function(error) {
					alert(JSON.stringify(error));
				});
			} else {
				alert('购物车中以存在');
			}
		}, function(error) {});
	});
})